<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2023-02-04 11:43:17
 * @Last Modified time: 2023-02-04 13:49:20
 */
namespace app\common\dao\store;

use frank\base\BaseDao;
use app\common\model\store\GoodsCollectionModel;

/**
 * Class GoodsCollectionDao
 * @package app\common\dao\store
 */
class GoodsCollectionDao extends BaseDao
{
    /**
     * 设置模型名
     */
    protected function setModel(): string
    {
        return GoodsCollectionModel::class;
    }

    public function status($goodsId = 0,$uid = 0){
    	$filter = [
    		'goods_id'=>$goodsId,
    		'user_id'=>$uid
    	];
    	return is_null($this->search($filter)->limit(1)->find())?false:true;
    }

    /**
     * 获取列表
     */
    public function getGoodsCollectionList(?array $where = [], int $page, int $limit, ?array $field = [], ?array $with = [])
    {
        return $this->search($where)->with($with)->field($field ?? ['*'])->order('create_time DESC')->page($page)->paginate($limit);
    }
}

